﻿using System.Collections.Generic;
using System.Linq;
using LINQtoFxCop.Core;

namespace LINQtoFxCop.Flaws.Naming
{
  internal class NamingDoNotPrefixEnumValuesWithTypeName : FlawsIntrospectionRule
  {
    public NamingDoNotPrefixEnumValuesWithTypeName()
      : base("NamingDoNotPrefixEnumValuesWithTypeName")
    { }

    protected override IEnumerable<QueryResult> Query()
    {
      return
        from @enum in Enums
        where @enum.Members.HasItemWhen(field => field.Name.Name.StartsWith(@enum.Name.Name))
        select Result(@enum);
    }
  }
}
